//获取当前用户token
function getCurrentToken(){
	token = '';
	userObj = window.localStorage.getItem('current_user');
	if(userObj){
		userObj = JSON.parse(userObj);
		current_time = (new Date()).getTime() / 1000;
		if(userObj.expire_time > current_time){
			token = userObj.token;
		}else{
			window.localStorage.clear();
		}
	}
	
	return token;
}

//设置登录用户
function setCurrentUser(token = ''){
	expire_time = (new Date()).getTime() / 1000 + 3600*5.5;
	userObj = {
		token:token,
		expire_time:expire_time
	}
	window.localStorage.setItem('current_user',JSON.stringify(userObj));
}

//登出
function clearCurrentUser(){
	window.localStorage.clear();
}

//调用登录接口
function getIn(username = '',password = ''){
	result = '';
	$.ajax({
		url:'https://cutezz.cn/admin/login',
		type:"post",
		async:false,
	    data:{
			'username':username,
			'password':password,
		},
		success:function(data){
			code = data.code;
			if(code == 200){
				result = data.result.token;
			}
		},
		error:function(){
			layer.msg('登录出错');
		}
	})
	return result;
}